package com.jl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jl.commons.result.PageDataInfo;
import com.jl.mapper.InspectionTaskMapper;
import com.jl.model.InspectionTask;
import com.jl.service.IInspectionTaskService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 巡检指令表 服务实现类
 * </p>
 *
 * @author JiangJian
 * @since 2019-03-18
 */
@Service
public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper, InspectionTask> implements IInspectionTaskService {


    @Override
    public void selectInspectionTaskDataGrid(PageDataInfo<Map<String, Object>> pageDataInfo, QueryWrapper<InspectionTask> qw) {
        Page<Map<String,Object>> page = new Page<>();
        page.setSize(pageDataInfo.getSize());
        page.setCurrent(pageDataInfo.getCurrent());
        List<Map<String,Object>> mapList =baseMapper.selectDataGrid(page,qw);
        pageDataInfo.setTotal(page.getTotal());
        pageDataInfo.setRecords(mapList);
    }

    /**
     * 插入执行结果的同时，也要把状态改为2 执行完成
     * @param id id
     * @param result 执行结果
     */
    @Override
    public boolean updateInspectionTaskResult(Long id, Long operatorId,String result) {
        return baseMapper.updateInspectionTaskResult(id,operatorId,result) >0;
    }
}
